module EventEditor
  module Route
    class MoveWaitDialog
     def self.show(base, &func)
       dialog = Gtk::Dialog.new("Move Wait",
               base,
               Gtk::Dialog::MODAL |
               Gtk::Dialog::DESTROY_WITH_PARENT,
               ["OK", Gtk::Dialog::RESPONSE_OK],
               ["Cancel", Gtk::Dialog::RESPONSE_CANCEL]
               )

        hbox = Gtk::HBox.new
        hbox.set_border_width(5)
        hbox.add(wait_input = Gtk::SpinButton.new(0, 99, 1))
        hbox.add(Gtk::Label.new('frames'))
        dialog.vbox.add(hbox)
        dialog.vbox.show_all

        # run
        dialog.run do |response|
          if response == Gtk::Dialog::RESPONSE_OK
            func.call(wait_input.value.floor)
          else
            func.call(:cancel)
          end
          dialog.destroy
        end
      end
      
      def self.command_to_s(args)
        return "MoveWait = #{args[1]}"
      end
    end
  end
end